﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace LibFriesland_Campina_CRM
{
    class DalShop
    {
        //Lay Shop theo shop_numid
        public static BizShop getShopbyID(string pShop_charid)
        {
            Friesland_Campina_CRM_DataContext db = new Friesland_Campina_CRM_DataContext(new MySqlConnection(Thuvien.getConnString()));
            try
            {
                var shop = db.Shop.Single(p => p.ShopCharID == pShop_charid);
                return new BizShop(shop.ShopCharID, shop.Name, shop.Address, Convert.ToDouble(shop.Latitude), Convert.ToDouble(shop.Longitude));
            }
            catch(Exception ex)
            {
                return null;
            }
        }
    }
}
